<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("comld", $con);
$dateTime = date("Y-m-d",strtotime("-1 day"));
#$dateTime = '2012-03-28';
$logdate =  mysql_query("SELECT DISTINCT whatdate FROM `comld_query`");
while($everylogdate = mysql_fetch_array($logdate))
{
  mysql_query("INSERT INTO comld_query_temp
SELECT max( id ),_499cents1,
  _499cents2,
  _299cents1,
  _199cents1,
  _099cents1,
  _099cents2,
  _999cents1,
  _999cents2,
  _1999cents1,
  _1999cents2,
  _9999cents1,
  _9999cents2,
  _4999cents1,
  _4999cents2,
  _199cents2,
  _299cents2,
  nGoldGainFromGameToday,
  nGoldConsumeToday,
  nGameOverToday,
  arrItemConsumeToday,
  InnoKiller,
  LandMine,
  AirStrike,
  Tower,
  TowerBullet,
  nLoginTimesToday,
  ltWeaponBuyToday,
  nGoldGainFromIAPToday,
  fGameTimeToday,
  nTCGainToday,
  InnoKiller_arrItemBuyToday,
  LandMine_arrItemBuyToday,
  AirStrike_arrItemBuyToday,
  Tower_arrItemBuyToday,
  TowerBullet_arrItemBuyToday,
  nTCConsumeToday,
  nStartGameToday,
  ltGameBreakOutToday,
  totalarrScene,
  Credit,
  Ready,
  Menu,
  Map,
  Help,
  options,
  IAP,
  Shop,
  Scene0,
  Scene1,
  totalnGoldGainTotal,
  totalltWeapon,
  FirstLoginTime,
  totalfGameTimeTotal,
  totalnTCGainTotal,
  totalnTCNow,
  totalarrItem,
  InnoKiller_totalarrItem,
  LandMine_totalarrItem,
  AirStrike_totalarrItem,
  Tower_totalarrItem,
  TowerBullet_totalarrItem,
  totalnGoldNow,
  Jailbreak,
  deviceid,
  whatdate,
  gamename,
  createdate,
  date
FROM comld_query
WHERE whatdate = '$everylogdate[whatdate]'
GROUP BY deviceid");
}

#mysql_query("INSERT INTO dinocap2hd SELECT NULL,dayGetMoney, dayIap1BuyTimes,dayIap2BuyTimes,dayIap3BuyTimes,dayIap4BuyTimes,dayIap5BuyTimes,dayIap6BuyTimes,dayIapMoney,dayPlayTime,dayTotalTime,dayUI1TapCount,dayUI2TapCount,dayUI3TapCount,dayUI4TapCount,dayUI5TapCount,dayUI6TapCount,dayUI7TapCount,dayUI8TapCount,dayUI9TapCount,dayUsedMoney,firstlogindata,firstlogin,fromNotificationCount,isjailbreak,lastMission,lastMissionState,lastMissionType,lastTapUI,mission1End,mission1Exit,mission1Retry,mission1Select,mission2End,mission2Exit,mission2Retry,mission2Select,mission3End,mission3Exit,mission3Retry,mission3Select,mission4End,mission4Exit,mission4Retry,mission4Select,mission5End,mission5Exit,mission5Retry,mission5Select,mission6End,mission6Exit,mission6Retry,mission6Select,mission7End,mission7Exit,mission7Retry,mission7Select,mission8End,mission8Exit,mission8Retry,mission8Select,nowMoney,player1DayExp,player1Level,player1TotalExp,player1Weapon1Level,weapon1IsUpdate,player1Weapon2Level,weapon2IsUpdate,player1Weapon3Level,weapon3IsUpdate,player1Weapon4Level,weapon4IsUpdate,player1Weapon5Level,weapon5IsUpdate,player1Weapon6Level,weapon6IsUpdate,player1WeaponBulletCount,player1WeaponBulletMoney,player1WeaponUpdateCount,player1WeaponUpdateMoney,player2DayExp,player2Level,player2TotalExp,player2Weapon1Level,weapon1IsUpdate_2,player2Weapon2Level,weapon2IsUpdate_2,player2Weapon3Level,weapon3IsUpdate_2,player2Weapon4Level,weapon4IsUpdate_2,player2Weapon5Level,weapon5IsUpdate_2,player2Weapon6Level,weapon6IsUpdate_2,player2WeaponBulletCount,player2WeaponBulletMoney,player2WeaponUpdateCount, player2WeaponUpdateMoney , player3DayExp, player3Level, player3TotalExp, player3Weapon1Level,weapon1IsUpdate_3,player3Weapon2Level,weapon2IsUpdate_3,player3Weapon3Level,weapon3IsUpdate_3,player3Weapon4Level,weapon4IsUpdate_3,player3Weapon5Level,weapon5IsUpdate_3,player3Weapon6Level,weapon6IsUpdate_3,player3WeaponBulletCount,player3WeaponBulletMoney,player3WeaponUpdateCount,player3WeaponUpdateMoney,player4DayExp,player4Level,player4TotalExp,player4Weapon1Level,weapon1IsUpdate_4,player4Weapon2Level,weapon2IsUpdate_4,player4Weapon3Level,weapon3IsUpdate_4,player4Weapon4Level,weapon4IsUpdate_4,player4Weapon5Level,weapon5IsUpdate_4,player4Weapon6Level,weapon6IsUpdate_4,player4WeaponBulletCount,player4WeaponBulletMoney,player4WeaponUpdateCount,player4WeaponUpdateMoney,player5DayExp,player5Level,player5TotalExp,player5Weapon1Level,weapon1IsUpdate_5,player5Weapon2Level,weapon2IsUpdate_5,player5Weapon3Level,weapon3IsUpdate_5,player5Weapon4Level,weapon4IsUpdate_5,player5Weapon5Level,weapon5IsUpdate_5,player5Weapon6Level,weapon6IsUpdate_5,player5WeaponBulletCount,player5WeaponBulletMoney,player5WeaponUpdateCount,player5WeaponUpdateMoney,totalMoney,totalTime,deviceid,gamename,whatday,createdate,date  FROM  dinocap2hd_query_temp");
#mysql_query("rename table dinocap2hd_query_temp to dinocap2hd");
mysql_close($con);
?>